﻿using System;
using System.Collections.Generic;
using System.Text;
using SubSonic;
using Medianamik.Core;

namespace Medianamik.UI.Web.Membership
{
    public static class SubSonicExtension
    {
        public static  string ToSqlString(this Where where)
        {
            return String.Concat(" and ", where.ColumnName,
                Where.GetComparisonOperator(where.Comparison), where.ParameterValue);
        }

        public static string  ToSqlString(this IEnumerable<Where> wheres)
        {
            var sqlBuilder = new StringBuilder();

            wheres.ForEach(w => sqlBuilder.Append(w.ToSqlString()));

            return sqlBuilder.ToString();
        }
    }
}
